import axios from "./request";
// import {formatDate} from '@lib/index'
const fishing = "/api/v1.0/fishing"; //鱼业

// console.log(axios, fishing);

const fishings = {
	// 获取任务列表
	getTaskList(pageNum = 1, pageSize = 10, planName = "", planStatus = 0) {
		return axios
			.post(`${fishing}/findPlanByCondition`, {
				params: {
					pageNum,
					pageSize,
					planName,
					planStatus
				},
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	// 创建任务
	createTask(taskFrom) {
		console.log(taskFrom);
		return axios
			.post(`${fishing}/plan/create`, {
				params: taskFrom,
			})
			.then(res => {
				console.log(res)
				return Promise.resolve(res);
			})
			.catch(err => {
				return Promise.resolve(err);
			});
	},
	//下发任务
	releaseTask(id) {
		return axios
			.post(`${fishing}/task/release`, {
				params: {
					id,
				},
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	//停用任务
	recall() {
		return axios
			.post(`${fishing}/recall`, {
				params: {
					id: 1,
				},
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	//修改地块信息
	setPlotMSG(obj) {
		return axios
			.post(`${fishing}/landInfo/update`, {
				params: obj,
			})
			.then(res => {
				return Promise.resolve(res);
			})
			.catch(err => {
				return Promise.resolve(err);
			});
	},
	//查看采集要求
	getGatheringRequirements(id) {
		return axios
			.post(`${fishing}/gatheringRequirements`, {
				params: { id: id },
			})
			.then(res => {
				return Promise.resolve(res);
			})
			.catch(err => {
				return Promise.resolve(err);
			});
	},
	// 首页/数据资源/生产主体库 管敏乾
	getSubjectList(page) {
		return axios
			.post(`${fishing}/subject/getSubjectInfoList`, {
				params: page,
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	// 首页/数据资源/生产主体库查看详情 管敏乾
	getSubjectViewDetails(subjectId) {
		return axios
			.post(`${fishing}/subject/getSubjectInfo`, {
				params: {
					subjectId
				},
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	//首页/数据资源/生产主体库新增 黄柏森
	getInsertSubjectInfo(InsertSubjectInfoFrom) {
		return axios
			.post(`${fishing}/subject/subject/create`, {
				params: InsertSubjectInfoFrom,
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	//首页/数据资源/生产主体库编辑 黄柏森
	putSubjectInfo(InsertSubjectInfoFrom) {
		return axios
			.post(`${fishing}/subject/putSubjectInfo`, {
				params: InsertSubjectInfoFrom,
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	//修改审核主体与地块信息 韩扬靖
	getAuditData(planId) {
		return axios
			.post(`${fishing}/audit`, {
				params: {
					planId,
				},
			})
			.then(res => Promise.resolve(res))
			.catch(err => Promise.reject(err));
	},
	//获取村镇信息 韩扬靖
	getVillageData() {
		return axios
			.post(`${fishing}/selectVillage`)
			.then(res => Promise.resolve(res))
			.catch(err => Promise.reject(err));
	},
	planEnd(planId) {
		return axios
			.post(`${fishing}/end`, {
				params: {
					planId,
				},
			})
			.then(result => {
				return Promise.resolve(result);
			})
			.catch(err => {
				console.log(err);
			});
	},
	myPlan(current, pageSize, planName, planStatus) {
		return axios.post(`${fishing}/page`, {
			params: {
				current,
				pageSize,
				planName,
				planStatus,
			},
		}).then((result) => {
			return Promise.resolve(result)
		}).catch((err) => {
			console.log(err);
		});
	},
};

export default fishings;
